import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import { createApp } from 'vue'
import App from './App.vue'
import  router, { setupRouter } from './router'
import { setupStore } from '@/store'
import '@/styles/index.styl'

import { setupNaive } from '@/plugins/naive'
import { AppProvider } from '@/components/Application'
import { setupGlobalMethods } from '@/plugins/globalMethods'


async function bootstrap() {
  const appProvider = createApp(AppProvider)
  const app = createApp(App)

  // 全局注册常用的naive-ui组件
  setupNaive(app)

  // 状态管理
  setupStore(app)


  // 优先挂载Provider。使得axios中可以使用Message等组件
  appProvider.mount('#appProvider', true)
  
  // 注册全局方法  
  setupGlobalMethods(app)
  // 挂载路由
  await setupRouter(app)

  // 路由准备好后挂载app实例
  await router.isReady()
  app.mount('#app', true)
}

void bootstrap()
